package com.qcby.pushservice.web.controller;

import cn.hutool.core.bean.BeanUtil;
import com.qcby.framework.common.pojo.PageParam;
import com.qcby.framework.common.pojo.PageResult;
import com.qcby.framework.common.pojo.Result;
import com.qcby.pushservice.base.dto.BusinessClientDTO;
import com.qcby.pushservice.base.service.IBusinessClientService;
import com.qcby.pushservice.web.entity.param.BusinessClientParam;
import com.qcby.pushservice.web.entity.vo.BusinessClientVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 业务客户端控制器
 *
 * @author cong.zhen
 * @date 2023/05/07
 */
@RestController
@RequestMapping("admin/push-service/client/")
public class BusinessClientController {

    @Resource
    private IBusinessClientService businessClientService;
    /**
     * 页面信息
     *
     * @param pageParam           页面参数
     * @param businessClientParam 业务客户端参数
     * @return {@link Result}<{@link PageResult}<{@link BusinessClientVO}>>
     */
    @GetMapping("page-info")
    public Result<PageResult<BusinessClientVO>> pageInfo(PageParam pageParam, BusinessClientParam businessClientParam){

        BusinessClientDTO businessClientDTO = BeanUtil.copyProperties(businessClientParam,BusinessClientDTO.class);
        Result<PageResult<BusinessClientDTO>> pageResultResult = businessClientService.demoPageQuery(businessClientDTO, pageParam);
        List<BusinessClientVO> businessClientVOS = BeanUtil.copyToList(pageResultResult.getData().getList(), BusinessClientVO.class);
        PageResult<BusinessClientVO> pageResult = new PageResult();
        pageResult.setList(businessClientVOS);
        pageResult.setTotal(pageResultResult.getData().getTotal());
        return Result.getSuccessResult(pageResult);

    }
}
